package leetcode;

/**
 * @创建人 MBY381
 * @创建时间 2022/5/10 19:07
 * @描述 暂无
 */
public class Solution162 {
    public int findPeakElement(int[] nums) {
        if (nums.length < 2) { //应为2而不是3
            return 0;
        }
        int left = 0, right = nums.length-1;
        while (left < right) {
            int mid = (left + right) / 2;
            if (nums[mid]>nums[mid+1]){
                right=mid;
            }
            else {
                left=mid+1;
            }
        }
        return right;
    }
}
